#ifndef __INCLUDED_CBL_STATIC_VECTOR_H__
#error "CBL_StaticVector.hpp must not be used directly. Use CBL_StaticVector.h instead."
#else
#ifndef __INCLUDED_CBL_STATIC_VECTOR_HPP__
#define __INCLUDED_CBL_STATIC_VECTOR_HPP__

#define STATICVECTOR_TYPE CStaticVector<TType>

template <typename TType>
STATICVECTOR_TYPE::CStaticVector(uint32 _RowSize)
: m_RowSize(_RowSize)
, m_CurrentRowIndex(0)
{
	m_BasePointer.reserve(10);
	m_BasePointer.push_back(new TType[m_RowSize]);
}

// ---------------------------------------------------------------------------------------------------------------------

template <typename TType>
STATICVECTOR_TYPE::~CStaticVector()
{
	Clear();
}

// ---------------------------------------------------------------------------------------------------------------------

template <typename TType>
void STATICVECTOR_TYPE::PushBack(TType& _rType)
{
	m_BasePointer.back()[m_CurrentRowIndex++] = _rType;
	if (m_CurrentRowIndex >= m_RowSize)
	{
		m_BasePointer.push_back(new TType[m_RowSize]);
		m_CurrentRowIndex = 0;
	}
}

// ---------------------------------------------------------------------------------------------------------------------

template <typename TType>
void STATICVECTOR_TYPE::Clear()
{
	while (!m_BasePointer.empty())
	{
		delete[] m_BasePointer.back();
		m_BasePointer.pop_back();
	}
}

// ---------------------------------------------------------------------------------------------------------------------

template <typename TType>
uint32 STATICVECTOR_TYPE::Size() const
{
	return ((m_BasePointer.size()-1) * m_RowSize) + m_CurrentRowIndex;
}

// ---------------------------------------------------------------------------------------------------------------------

template <typename TType>
TType& STATICVECTOR_TYPE::operator [] (uint32 _Index)
{
	uint32 Row = _Index / m_RowSize;
	uint32 Col = _Index % m_RowSize;
	return m_BasePointer[Row][Col];
}

// ---------------------------------------------------------------------------------------------------------------------

template <typename TType>
const TType& STATICVECTOR_TYPE::operator [] (uint32 _Index) const
{
	uint32 Row = _Index / m_RowSize;
	uint32 Col = _Index % m_RowSize;
	return m_BasePointer[Row][Col];
}

#endif
#endif